package com.demo.config;

import com.demo.entity.MinioProperties;
import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * MinIO配置类
 * @author ch3nw3i@gitee
 */
@Data
@Component
public class MinioConfig {

    @Autowired
    private MinioProperties minioProperties;

    @Bean
    public MinioClient getMinioClient() throws InvalidEndpointException, InvalidPortException {
        MinioClient minioClient = new MinioClient(minioProperties.getEndpoint(), minioProperties.getPort(),
                minioProperties.getAccessKey(), minioProperties.getSecretKey(), minioProperties.getSecure());
        return minioClient;
    }
}
